<template>
  <div class="search-list">
    <transition-group tag="ul" name="list">
      <li class="search-item" v-for="item in searches" :key="item" @click="selectItem(item)">
        <span class="text">{{item}}</span>
        <span class="icon" @click.stop="deleteOne(item)">
          <i class="icon-delete"></i>
        </span>
      </li>
    </transition-group>
  </div>
</template>

<script type="text/ecmascript-6">
export default {
  props: {
    searches: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    selectItem (item) {
      this.$emit('select', item)
    },
    deleteOne (item) {
      this.$emit('delete', item)
    }
  }
}
</script>

<style lang="stylus" scoped rel="stylesheet/stylus">
  @import '~common/stylus/variable';
  @import '~common/stylus/mixin';

  .search-list {
    .search-item {
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: $color-text-l;
      overflow: hidden;

      &.list-enter-active, &.list-leave-active {
        transition: all 0.4s;
      }

      &.list-enter, &.list-leave-to {
        height: 0;
      }

      .icon {
        display: flex;
        font-size: $font-size-small;
        extend-click();
      }
    }
  }
</style>
